x86/mm: Annotate gfn_get_* helpers as requiring non-NULL parameters
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 27 Jul 2016 17:34:39 +0000 (18:34 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 2 Aug 2016 16:21:21 +0000 (17:21 +0100)
commite9522e4932aaa7f083688b6612b5897839409260
tree477e6e5f3d3e6bd176c8f869e8ffeb6c4a4848d1
parente125fb0e4fce93862f61b5235aedacd1553ad40b
x86/mm: Annotate gfn_get_* helpers as requiring non-NULL parameters

Introduce and use the nonnull attribute to help the compiler catch NULL
parameters being passed to function which require their parameters not to be
NULL.  Experimentally, GCC 4.9 on Debian Jessie only warns of non-NULL-ness
from immediate callers, so propagate the attributes out to all helpers.

A sample error looks like:

mem_sharing.c: In function ‘mem_sharing_nominate_page’:
mem_sharing.c:884:13: error: null argument where non-null required (argument 3) [-Werror=nonnull]
             amfn = get_gfn_type_access(ap2m, gfn, NULL, &ap2ma, 0, NULL);
             ^

As part of this, replace the get_gfn_type_access() macro with an equivalent
static inline function for extra type safety, and the ability to be annotated.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
xen/include/asm-x86/p2m.h
xen/include/xen/compiler.h